package com.example.homeworkhelper.history;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.RequiresApi;

import com.example.homeworkhelper.history.bean.RecordData;
import com.example.homeworkhelper.result.ResultDisplayActivity;

import java.io.ByteArrayOutputStream;
import java.util.Base64;

public class IOnItemClickListener {

    @RequiresApi(api = Build.VERSION_CODES.O)
    public void onItemClick(int position, RecordData recordData, Activity activity){
        Intent intent = new Intent(activity, ResultDisplayActivity.class);
        System.out.println("+++++++++++++++++++++"+activity);
        Bundle bundle = new Bundle();
//        System.out.println("1:"+recordData.getSearch_id());
//        System.out.println("2:"+recordData.getItems());
//        System.out.println("3:"+recordData.getSearch_image());
//        System.out.println("4:"+recordData.getIs_marked());
//        System.out.println("5:"+recordData.getDev_id());
        bundle.putString("APIresult", recordData.getItems());
        byte[] bytes = recordData.getSearch_image();
        Bitmap bitmap = BitmapFactory.decodeByteArray(bytes,0,bytes.length);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        bitmap.compress(Bitmap.CompressFormat.JPEG, 50, bos);
        byte[] bb = bos.toByteArray();
        String image = android.util.Base64.encodeToString(bb, android.util.Base64.NO_WRAP);
        bundle.putString("Bitmap",image);
        bundle.putString("search_id", recordData.getSearch_id());
        System.out.println(recordData.getSearch_id());
        bundle.putInt("is_marked", recordData.getIs_marked());
        System.out.println(recordData.getIs_marked());
        intent.putExtras(bundle);
        System.out.println("******************");
        activity.startActivity(intent);
    }

//    private String bitmap = "iVBORw0KGgoAAAANSUhEUgAABDgAAAQ4CAIAAABjcvvYAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4nOzdO48kWXrw9+ecuGRlVXX19MxwuMuXC9ETXhkC5MoRIMiQR0s+AdIiQKxDfg0CBEGbn+A1BVkUIEO+JEeAjJcQVuRylzuX7rrkJSLOkZHdw93Z6dnpZObU6erfD41AT3fNREzWkxn5r7hkuri4iHNKKUXEPM/DMMzznHP+6U9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MSHh4fLy8v7+/v1en3W9T5VKaWrq6vDsdG+7/u+f/nyZSml67rH3rSmmcPTMofHMYenZQ6PYw5Pyxwexxye1lOdw7NfozKO43a7LaXc398vy3L4x+fPn7/v58w9lsvLy5cvXw7DcHt7u9/vu647jKNDpd/NHJ6WOTyOOTwtc3gcc3ha5vA45vC0nuocpr/6q7866wpKKdM0jeN4cXGRUvr5z3/+D//wD//4j/+omI+z2Wx+8pOf/PEf//GLFy9SSodjptM0ve/FfG7m8LTM4XHM4WmZw+OYw9Myh8cxh6f1VOfw7Lcnnuf54uIi53w47/DTTz/9x3/8x08++eT+/v6s632qPvvss5/97GfPnz+/u7s7/Ml6vb69vb28vHzcDWucOTwtc3gcc3ha5vA45vC0zOFxzOFpPdU57M990dI4jhGxLMvhHLNa6zAMpvBot7e34zju9/txHOd5PjyYV1dXj71drTOHp2UOj2MOT8scHsccnpY5PI45PK2nOoduVg0AADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gAAADNESoAAEBzhAoAANAcoQIAADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gAAADNESoAAEBzhAoAANAcoQIAADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gAAADNESoAAEBzhAoAANAcoQIAADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gAAADNESoAAEBzhAoAANAcoQIAADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gAAADNESoAAEBzhAoAANAcoQIAADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gAAADNESoAAEBzhAoAANAcoQIAADRHqAAAAM0RKgAAQHOECgAA0ByhAgAANEeoAAAAzREqAABAc4QKAADQHKECAAA0R6gA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